
export const GameStepArray = [
    "NextQuestion",
    "VerifyRealPerson",
    "VerifyRule",
    "StatisticsPlayer",
    "DisplayPlayer",
    "Title",
    "Option",
    "Answer",
    "Analysis",
    "StatisticsAnswer",
    "CurrentRank",
    "TotalRank",
]

export const isAllowNextStep = (pre_step: string, next_step: string) => {
    /**
     * 是否允许下一步，如果不允许，需要提示。
     * 判断输入的下一步名称是否在当前步骤之后的下一位，如果是则返回true，否则返回false
     * 游戏步骤必须逐次进行，不能跳跃，否则就是bug，需要限制。
    */
    if (pre_step !== next_step) {
        if (next_step === 'NextQuestion') {
            return true;
        } else {
            let current_index = GameStepArray.indexOf(pre_step);
            if(current_index !== -1) {
                if(current_index === GameStepArray.length-1) {
                    // 如果是最后一步，那么便不需要再判断
                    return GameStepArray[0] === next_step;
                } else {
                    return GameStepArray[current_index + 1] === next_step;
                }
            }
        }
    } else {
        // 如果两个步骤相同，那么返回false
    }
    return false;
}

/**
 * 节点名称——将视图中的节点名称统一存放在这里，方便管理
 * scene_name: {
 *      node_type: {
 *          node_name: {}
 *      }
 * }*/
export const NodeName = {
    'LiveRoomScene': {
        'Button': {
            'NextQuestionButton': 'NextQuestionButton',
            'VerifyRealPersonButton': 'VerifyRealPersonButton',
            'TitleButton': 'TitleButton',
            'OptionButton': 'OptionButton',
            'AnswerButton': 'AnswerButton',
            'AnalysisButton': 'AnalysisButton',
            'StatisticsAnswerButton': 'StatisticsAnswerButton',
            'CurrentRankButton': 'CurrentRankButton',
            'TotalRankButton': 'TotalRankButton',
            'VerifyRuleButton': 'VerifyRuleButton',
            'StatisticsPlayerButton': 'StatisticsPlayerButton',
            'DisplayPlayerButton': 'DisplayPlayerButton',
        },
        'EditBox': {
            'SecondsNumEditBox': 'SecondsNumEditBox',
            'LikesNumEditBox': 'LikesNumEditBox',
            'BarrageTextEditBox': 'BarrageTextEditBox',
        },
        'Sprite': {
            'BackgroundSprite': 'BackgroundSprite',
            'TeacherSprite': 'TeacherSprite',
            'StudentTopLeftSprite': 'StudentTopLeftSprite',
            'StudentTopRightSprite': 'StudentTopRightSprite',
            'StudentBottomLeftSprite': 'StudentBottomLeftSprite',
            'StudentBottomRightSprite': 'StudentBottomRightSprite',
            'BlackBoardTopLeftSprite': 'BlackBoardTopLeftSprite',
            'BlackBoardTopRightSprite': 'BlackBoardTopRightSprite',
            'BlackBoardBottomLeftSprite': 'BlackBoardBottomLeftSprite',
            'BlackBoardBottomRightSprite': 'BlackBoardBottomRightSprite',
            'TitleAnswerAnalysisSprite': 'TitleAnswerAnalysisSprite',
            'FloatControlBarSprite': 'FloatControlBarSprite',
            'VerifyRealPersonSprite': 'VerifyRealPersonSprite',
        },
        'Node': {
            'TeachersNode': 'TeachersNode',
            'StudentsNode': 'StudentsNode',
            'BlackBoardsNode': 'BlackBoardsNode',
            'OptionsNode': 'OptionsNode',
            'OperatorBarNode': 'OperatorBarNode',
        },
        'Label': {
            'TitleLabel': 'TitleLabel',
            'AnswerLabel': 'AnswerLabel',
            'AnalysisLabel': 'AnalysisLabel',
            'SecondsNumLabel': 'SecondsNumLabel',
            'LikesNumLabel': 'LikesNumLabel',
            'BarrageTextLabel': 'BarrageTextLabel',
        },
        'Toggle': {
            'LikesNumToggle': 'LikesNumToggle',
            'BarrageTextToggle': 'BarrageTextToggle',
        }
    },
    'CreateLiveRoomScene': {
        'Sprite': {
            'BackgroundSprite': 'BackgroundSprite',
            'CheckSprite': 'CheckSprite',
        },
        'Node': {
            'SelectNode': 'SelectNode',
            'SelectBoxNode': 'SelectBoxNode',
            'CheckOptionButtonNode': 'CheckOptionButtonNode',
            'CheckNode': 'CheckNode',
            'SubmitNode': 'SubmitNode',
        },
        'Button': {
            'SubjectButton': 'SubjectButton',
            'LabelButton': 'LabelButton',
            'PkModeButton': 'PkModeButton',
            'CloseButton': 'CloseButton',
            'SubmitButton': 'SubmitButton',
        }
    },
    'CreateLiveRoomSuccessScene': {
        'Sprite': {
            'BackgroundSprite': 'BackgroundSprite',
            'SuccessIconSprite': 'SuccessIconSprite',
        },
        'Widget': {
            'SuccessWidget': 'SuccessWidget',
        },
        'Label': {
            'SuccessTitleLabel': 'SuccessTitleLabel',
            'SuccessJumpLinkLabel': 'SuccessJumpLinkLabel',
        }
    },
    'CreateLiveRoomFailScene': {
        'Sprite': {
            'BackgroundSprite': 'BackgroundSprite',
            'FailIconSprite': 'FailIconSprite',
        },
        'Widget': {
            'FailWidget': 'FailWidget',
        },
        'Label': {
            'FailTitleLabel': 'FailTitleLabel',
            'FailJumpLinkLabel': 'FailJumpLinkLabel',
        }
    },
    'StreamerQueryScene': {
        'Sprite': {
            'BackgroundSprite': 'BackgroundSprite',
            'IconSprite': 'IconSprite',
            'CheckSprite': 'CheckSprite',
        },
        'Node': {
            'FormNode': 'FormNode',
            'CheckNode': 'CheckNode',
            'CheckOptionButtonNode': 'CheckOptionButtonNode',
        },
        'Button': {
            'LivePlatformButton': 'LivePlatformButton',
            'CloseButton': 'CloseButton',
            'SubmitButton': 'SubmitButton',
        },
        'Widget': {
            'LivePlatformNumberWidget': 'LivePlatformNumberWidget',
            'SubmitWidget': 'SubmitWidget',
        },
        'EditBox': {
            'LivePlatformNumberEditBox': 'LivePlatformNumberEditBox',
        }
    },
    'StreamerCreateScene': {
        'Sprite': {
            'BackgroundSprite': 'BackgroundSprite',
            'IconSprite': 'IconSprite',
            'CheckSprite': 'CheckSprite',
        },
        'Node': {
            'FormNode': 'FormNode',
            'CheckNode': 'CheckNode',
            'CheckOptionButtonNode': 'CheckOptionButtonNode',
        },
        'Button': {
            'LivePlatformButton': 'LivePlatformButton',
            'CloseButton': 'CloseButton',
            'SubmitButton': 'SubmitButton',
        },
        'Widget': {
            'LivePlatformNumberWidget': 'LivePlatformNumberWidget',
            'UsernameWidget': 'UsernameWidget',
            'PasswordWidget': 'PasswordWidget',
            'RePasswordWidget': 'RePasswordWidget',
            'SubmitWidget': 'SubmitWidget',
        },
        'EditBox': {
            'LivePlatformNumberEditBox': 'LivePlatformNumberEditBox',
            'UsernameEditBox': 'UsernameEditBox',
            'PasswordEditBox': 'PasswordEditBox',
            'RePasswordEditBox': 'RePasswordEditBox',
        },
        'Label': {
            'UsernameTooltipLabel': 'UsernameTooltipLabel',
            'PasswordTooltipLabel': 'PasswordTooltipLabel',
            'RePasswordTooltipLabel': 'RePasswordTooltipLabel',
        }
    },
}

export enum LocalStorageKeysEnum {
    // 验证真人JSON数据
    VerifyRealPersonJson,
    // 玩家答题JSON数据
    PlayerAnswerJson,
    // 本题排名JSON数据
    CurrentRankJson,
    // 累积排名JSON数据
    TotalRankJson,
}